package com.jht.mymvvm

import android.content.Intent
import android.os.Bundle
import android.view.View
import androidx.appcompat.app.AppCompatActivity
import com.jht.mymvvm.activity.dbpage.DbActivity
import com.jht.mymvvm.activity.homepage.HomepageActivity
import com.jht.mymvvm.activity.scollview.ScollActivity
import com.jht.mymvvm.databinding.ActivityMainBinding
import kotlinx.android.synthetic.main.activity_main.*

class MainActivity : AppCompatActivity(), View.OnClickListener {
    private lateinit var binding: ActivityMainBinding

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        binding = ActivityMainBinding.inflate(layoutInflater)
        val view = binding.root
        setContentView(view)

        binding.button.setOnClickListener(this)
        binding.button2.setOnClickListener(this)
        binding.button3.setOnClickListener(this)
    }

    override fun onClick(v: View?) {
        when (v?.id) {
            R.id.button -> {
                val intent = Intent(this@MainActivity, HomepageActivity::class.java)
                startActivity(intent)
            }
            R.id.button2 -> {
                val intent = Intent(this@MainActivity, DbActivity::class.java)
                startActivity(intent)
            }
            R.id.button3 ->{
                val intent = Intent(this@MainActivity, ScollActivity::class.java)
                startActivity(intent)
            }
            else -> {

            }
        }
    }
}